<template>
  <live-pusher
    v-if="pushConfig.url"
    :url="pushConfig.url"
    :muted="pushConfig.muted"
    :beauty="pushConfig.beauty"
    :aspect="pushConfig.aspect"
    :min-bitrate="pushConfig.minBitrate"
    :max-bitrate="pushConfig.maxBitrate"
    :debug="pushConfig.debug"
    @statechange="handlePusherStateChange"
    @netstatus="handlePusherNetstatus"
    autopush
    class="h-100"
    mode="RTC">
  </live-pusher>
</template>

<script>
  export default {
    data() {
      return {
        pushConfig: {
          url: 'rtmp://192.168.2.196:1935/live/STREAM_NAME', // 推流地址
          muted: false, // 静音
          beauty: true, // 美颜
          aspect: '9:16', // 推流比例
          minBitrate: 200, // 最低码率
          maxBitrate: 1000, // 最高码率
          debug: true // 是否开启调试
        }
      }
    },
    methods: {
      handlePusherStateChange(e) {
        console.log('推流状态变化', e)
      },
      handlePusherNetstatus(e) {
        console.log('推流网络状态变化', e)
      },
    }
  }
</script>

<style>
.h-100 {
  display: block;
  width: 100%;
  height: 100vh;
}
</style>
